Immutable Objects for a Java-Like Language
نویسندگان
چکیده
We extend a Java-like language with immutability specifications and a static type system for verifying immutability. A class modifier immutable specifies that all class instances are immutable objects. Ownership types specify the depth of object states and enforce encapsulation of representation objects. The type system guarantees that the state of immutable objects does not visibly mutate during a program run. Provided immutability-annotated classes and methods are final, this is true even if immutable classes are composed with untrusted classes that follow Java’s type system, but not our immutability type system.
منابع مشابه
Immutable Objects in Java
Immutability is a very useful and desirable property for objects. This paper investigates different possible notions of immutability for Java objects, to find out which notion is the most intuitive and useful, both when it comes to ways of enforcing immutability of objects, and when it comes to exploiting information about (im)mutability of objects in program verification and in various static ...
متن کاملObjects Dynamically Changing Class (work in Progress)
This paper represents work in progress; we shall be regularly updating it with proofs, examples and comparisons. Abstract. We suggest language features that allow objects to mutate, i.e. change their class membership at run-time. These features could extend an imperative, typed, class-based, object-oriented language like Java. We give an operational semantics for a mutation operation that chang...
متن کاملChanging Hashcodes: Objects, Intialisation, and Collections
Java requires objects’ hashcodes to be consistent with object equality, and to change only when an object’s equality changes. Equality dependent Java collections impose a stricter contextual contract on an objects’ equality, comparability, and hashcode methods: that they cannot change while those objects are in collections. By dynamically profiling 30 Java applications, we have determined that ...
متن کاملMining for Safety using Interactive Trace Analysis
This paper presents the results of a trace-based study of object and reference properties on a subset of the DaCapo benchmark suite with the intent to uncover facts about programs that can be leveraged by type systems, compilers and run-times. In particular, we focus on aliasing, and immutability, based on their recent application in the literature. To facilitate analyses like this one, we prev...
متن کاملBehavioral Subtyping is Equivalent to Modular Reasoning for Object-oriented Programs
Behavioral subtyping is an established idea that enables modular reasoning about behavioral properties of object-oriented programs. It requires that syntactic subtypes are behavioral refinements. It validates reasoning about a dynamically-dispatched method call, say E .m(), using the specification associated with the static type of the receiver expression E . For languages with references and m...
متن کامل